package day06;


import java.util.Scanner;

/**
 * Created by Shinelon on 2016/9/19.
 */
public class ATM {

    private double balance =3000;

    public static void main(String[] args) {
        ATM bbb =new ATM();
        Scanner scan =new Scanner(System.in);
        while (true) {
            System.out.println("欢迎使用ATM机!\n 1,查询余额 2，取钱 3，存钱 4，退卡");
            int read = scan.nextInt();
            switch (read) {
                case 1:
                    bbb.chamoney();
                    break;
                case 2:
                    bbb.qu(scan);
                    break;
                case 3:
                    bbb.cun(scan);
                    break;

            }
            if (read==4){
                bbb.tui();
                break;
            }
        }
    }
    public void chamoney(){
        System.out.println("您的余额为：" + balance);
    }
    public  void qu(Scanner scan ){
        System.out.println("请输入要去的金额：");
        int quan =scan.nextInt();
        if (quan%100==0){
            if (quan>balance){
                System.out.println("余额不足！");
            }else {
                System.out.println("取现成功！");
                balance-=quan;
            }
        }else {
            System.out.println("没零钱！");
        }

    }
    public void cun(Scanner scan){
        System.out.println("请输入要存的金额：");
        int cuan =scan.nextInt();
        if (cuan%100==0){
            System.out.println("存钱成果!");
            balance+=cuan;
        }else {
            System.out.println("存钱失败！");
        }
    }
    public void tui(){
        System.out.println("欢迎再次使用！");
    }
}
